package com.example.administrator.activity_to_activity;

import android.content.ClipData;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;


public class FirstActivity extends AppCompatActivity {

    private Button mlogin;
    private EditText maccount;
    private EditText mpassword;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_first);

        //添加组件
        mlogin = (Button) this.findViewById(R.id.loging);
        maccount = (EditText) this.findViewById(R.id.account);
        mpassword = (EditText) this.findViewById(R.id.password);

        //添加按钮监听
        mlogin.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                if (TextUtils.isEmpty(maccount.getText().toString().trim())) {
                    Toast.makeText(FirstActivity.this, "输入帐号为空！",Toast.LENGTH_SHORT).show();
                    return;
                }
                if(TextUtils.isEmpty(mpassword.getText().toString().trim())){
                    Toast.makeText(FirstActivity.this,"输入密码为空！",Toast.LENGTH_SHORT).show();
                    return;
                }

                    Intent intent=new Intent(FirstActivity.this,SecondActivity.class);
                   // Bundle bundle =new Bundle();
                 //   bundle.putString("account", maccount.getText().toString());
                  //  bundle.putString("password",mpassword.getText().toString());
                    intent.putExtra("account",maccount.getText().toString().trim());
                    intent.putExtra("password",mpassword.getText().toString().trim());
                    FirstActivity.this.startActivity(intent);

            }
        });

    }

}
